package cn.cy.behavior.state.general;

/**
 * @author yangxq
 * @desc
 * @date 2025-05-09
 */
public class Elevator {

    // [STOPPED, MOVING_UP, MOVING_DOWN]
    private String state;

    public Elevator() {
        state = "STOPPED"; // 初始状态为停止
    }

    public void up() {
        if ("STOPPED".equals(state)) {
            System.out.println("电梯正在向上移动...");
            state = "MOVING_UP";
        } else {
            System.out.println("电梯无法向上移动，当前状态: " + state);
        }
    }

    public void down() {
        if ("STOPPED".equals(state)) {
            System.out.println("电梯正在向下移动...");
            state = "MOVING_DOWN";
        } else {
            System.out.println("电梯无法向下移动，当前状态: " + state);
        }
    }

    public void stop() {
        if ("MOVING_UP".equals(state) || "MOVING_DOWN".equals(state)) {
            System.out.println("电梯停止...");
            state = "STOPPED";
        } else {
            System.out.println("电梯已经停止。");
        }
    }

}
